<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="/Templates/cloudiary.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- InstanceBeginEditable name="doctitle" -->
<title>Cloudiary</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<script type="text/javascript" src="Js/jquery.js"></script>
<script type="text/javascript" src="Js/slider.js"></script>
<!-- InstanceEndEditable -->
<link href="CSS/css.css" rel="stylesheet" type="text/css" />
</head>

<?php
	include('userlock.php');
	if($_SERVER["REQUEST_METHOD"] == "POST")
	{
		$newtype=addslashes($_POST['privacy_type']);
		$ID=addslashes($_POST['viewID']);
		$sql1="UPDATE post SET privacy_type='$newtype' WHERE user_email='$login_session' AND post_ID='$ID'";

		mysql_query($sql1);
	}
	
	$single_page=5;
	$query="SELECT * FROM post WHERE user_email='$login_session'";
    $query_name=mysql_query($query);
    $count=mysql_num_rows($query_name);
	$total_pages=ceil($count/$single_page);

    if(isset($_GET['page']) && is_numeric($_GET['page']))
    {
      $obtain_page=$_GET['page'];
      if($obtain_page>0 && $obtain_page<=$total_pages)
      {
        $starting_page=($obtain_page-1)*$single_page;
        $ending_page=$starting_page+$single_page;
      }
      else
      {
        $starting_page=0;
        $ending_page=$starting_page+$single_page;
      }
    }
    else
    {
      $starting_page=0;
      $ending_page=$starting_page+$single_page;
    }        
    
    
?>


<body>
<div id="container">
<div id="wrapper">

<div id="header">
<!-- InstanceBeginEditable name="header" -->
<div class="welcome">
<?php include('welcomeuser.php'); ?>
</div>
<!-- InstanceEndEditable -->

<img src="Assets/cloud diary low-01(trans).png" alt="CloudDiary" width="75" height="45" style="padding:5px 10px;" /> <br />
</div>

<div id="main">
<!-- InstanceBeginEditable name="main" -->
<ul class="dropdown">
<li><a href="Home.php" class="linkStraight">Home &nbsp; &nbsp;</a></li>
<li><a href="#" class="linkDown" id="classification">Classifications &nbsp; &nbsp;</a>
	<ul class="sub_menu" id="menu1">
    <li> <a href="PublicClassification.php"> Public &nbsp; </a> </li>
    <li> <a href="FriendClassification.php"> Friend &nbsp; </a> </li>
    </ul>
</li>
<li><a href="#" class="linkDown" id="friends">Friends &nbsp; &nbsp;</a>
	<ul class="sub_menu" id="menu2">
    <li> <a href="Friends.php"> Search Friends &nbsp; </a> </li>
    <li> <a href="CurrentFriends.php"> Current Friends &nbsp; </a> </li>
    <li> <a href="Send.php"> Sending Request &nbsp; </a> </li>
    <li> <a href="Receive.php"> Pending Request &nbsp; </a> </li>
    </ul>
</li>
<li><a href="#" class="linkDown" id="posts">Posts &nbsp; &nbsp;</a>
	<ul class="sub_menu" id="menu3">
    <li> <a href="NewPost.php"> New Post &nbsp; </a> </li>
    <li> <a href="ViewPosts.php">  View All Posts &nbsp; </a> </li>
    </ul>
</li>
<li><a href="Privacy.php" class="linkStraight">Privacy Settings &nbsp; &nbsp;</a></li>
</ul>

<div id="content">
<div id="page">
<?php
	echo"<p><strong>Page: &nbsp;</strong>";
    for($a=1;$a<=$total_pages;$a++)
    {
      echo"<a href='Privacy.php?page=$a'>$a</a>"." | ";
    }
?>
</div>
<?php
    echo"</p>";
?>

<table border="0" width="100%" style="margin-left:auto; margin-right:auto;">
<?php
$q = $query . "LIMIT $starting_page,$single_page";
$q=mysql_query($q);

for($a=$starting_page;$a<$ending_page;$a++)
{
    if($a == $count){
		break;
    }
	
	while($data_fetch=mysql_fetch_array($q))
    {
		echo"<tr>";
		echo"<td width='150' align='center' rowspan='2'>";
		echo" <img src='display_photo.php?id=".$data_fetch['user_email']."' alt='User picture'  width='150' height='170' style='border:1px solid #69F; padding:2px' /> </td>";
		echo"<td width='20' rowspan='2'> &nbsp; </td>";
		echo "<td width='620' rowspan='2'  style='border-left:solid 1px #69F'> <p style='font-size:16px;font-weight:bold'> &nbsp; Topic: ".$data_fetch['post_topic']." </p>";
		echo "&nbsp;".substr($data_fetch['post'], 0, 300)." <br /> <br />";
		echo "&nbsp; <a href='Post.php?id=".$data_fetch['post_ID']."'> Read More &raquo; </a> <br /> <br />";
		echo "<table border='0' width='100%' height='5px' style='color:#999; font-size:11px'> <tr>
			<td width='50%' align='center'> Date:&nbsp;".$data_fetch['post_date']."&nbsp;".$data_fetch['post_time']."</td>";
		echo "<td width='50%' align='center'> Last Update: &nbsp;".$data_fetch['post_edit_date']."&nbsp;".$data_fetch['post_edit_time']."</td> </tr> </table> </p> </td>";
		echo "<td height='106' align='right'>";
?>
<p align="right">
<form method="post">
<select name="privacy_type" >
<option <?php if (  $data_fetch['privacy_type'] == 'public' ): ?> selected="selected"<?php endif; ?> > public </option>
<option <?php if (  $data_fetch['privacy_type'] == 'private to self' ): ?> selected="selected"<?php endif; ?> > private to self</option>
<option <?php if (  $data_fetch['privacy_type'] == 'private to friends' ): ?> selected="selected"<?php endif; ?> > private to friends</option>
</select>
<input type="hidden" name="viewID" value="<?php echo $data_fetch["post_ID"]; ?>"/>
&nbsp; </p> </td>
</tr>
<tr> <td> <p align='right'> <input type='image' src='Assets/buttonUpdate.png' value='Update' /> &nbsp; </p> </td> </tr>
</form>	
<?php
echo "<tr> <td colspan='4' height='5px' style='border-bottom:solid 1px #69F'> &nbsp;  </td> </tr>";
echo "<tr> <td colspan='4' height='5px'> &nbsp;  </td> </tr>";
}
}
?>
</table>
</div>
<!-- InstanceEndEditable -->
</div>
</div>
</div>
<div id="footer">
<p align="center"> &copy; &nbsp; 2012 CloudDiary </p>
</div>
</body>
<!-- InstanceEnd -->
</html>